package com.gwtprocessingjs.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * This class demonstrates rendering a very simple Processing.js
 * script in a canvas element.
 */
public class ProcessingJs implements EntryPoint {
	
	// UI Elements.
	private final FlowPanel back = new FlowPanel();
	
	@Override
	public void onModuleLoad() {
		back.add(new Label("Rendering using processing JS calls."));
		initializeCanvas();
		RootPanel.get("gwt").add(back);
	}
	
	/**
	 * A GWT Native method used to make calls into the JS code.
	 * This method creates a Processing instance and associates it
	 * with the canvas element defined in the static HTML file.
	 */
	native void initializeCanvas() /*-{
		$wnd.initializeCanvas();
	}-*/;
}
